home *** CD-ROM | disk | FTP | other *** search
Text File | 1993-10-06 | 534 b | 24 lines | [TEXT/MPAD] |
- -- Solve for coefficients of a polynomial that goes through n data points.
-
- data = read(xydata)
- plot data[1:n]
-
- x[i]=data[i,1] dim[n] -- separate x and y
- y[i]=data[i,2] dim[n]
-
- f(x)[j] = x^(j-1) -- polynomial
-
- -- construct matrix using x data points
- A[i,j] = f(x[i])[j] dim[n,n]
-
- -- solve for coeffs that give y points
- c:=solve(A,y):
- c:{0.797,3.863,-0.715,0.057,-0.002,0.000}
-
- n=6
- plot sum((c*f(X))[i],i,1,n)
-
- ----general equation solver
- solve(A,B)[j] = det(cram(A,B,j))/det(A)
- cram(A,B,k)[i,j] = A[i,j] when j≠k, B[i] dim[count(B)]
-